package com.holi.hiteacher.activity;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import java.util.ArrayList;

/**
 * Created by Joshua Wong on 2016/10/22.
 */

public class BaseActivity extends AppCompatActivity {
    public static final String TAG = "holi";
    private static ArrayList<Activity> atyList = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        atyList.add(this);
        //禁止转屏
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        atyList.remove(this);
    }

    public static void removeAllAty() {
        for (Activity activity : atyList) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }
}
